﻿package src.utils {
	import flash.utils.getTimer;
	
	public class FpsCounter {
		private var currentFrame:int = 0;
		private var fps:int = 0;
		private var startTime:Number = 0;

		public function FpsCounter() {
			startTime = getTimer();
		}

		public function getFps():int {
			return fps;
		}

		public function tick():void {
			currentFrame++;
			if (getTimer() - startTime >= 1000) {
				fps = currentFrame;
				currentFrame = 0;
				startTime = getTimer();
			}
		}
	}
}